package com.rollawizards.arena
{
    public class TimeStepBased
    {
        private var children:Vector.<TimeStepBased>;

        public function TimeStepBased(parent:TimeStepBased = null)
        {
            children = new Vector.<TimeStepBased>();
            if (parent != null)
            {
                parent.addChild(this);
            }
        }

        public function addChild(child:TimeStepBased):void
        {
            children.push(child);
        }

        public function removeChild(child:TimeStepBased):void
        {
            children = children.splice(0, 1, child);
        }

        public function step():void
        {
            for (var i:int = 0; i < children.length; ++i)
            {
                children[i].step();
            }

            ownStep();
        }

        protected function ownStep():void
        {
        }
    }
}